This repository was archived by the owner on Aug 7, 2021. It is now read-only.
fix: fix "ERROR in Must have a source file to refactor." error from ngCompilerPlugin on test
command
#859
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The "ERROR in Must have a source file to refactor." error is thrown when
tns test android --path <projectPath> --bundle
command is executed.This error is thrown from
AngularCompilerPlugin
when the path tomain.ts
file is not correct. We provided the path tomain.ts
file here. As this path is built usingpath.resolve
andappPath
is relative path, the resulting path is still not an absolute path. In this case NodeJS uses current working directory as described here. In other words, in this caseresolve(appPath, entryModule)
is equal tojoin(process.cwd(), appPath, entryModule)
.NativeScript CLI starts 2 webpack processes on test command - one from
nativescript-dev-webpack
plugin and another one fromkarma-webpack
plugin.When the webpack process is started from
nativescript-dev-webpack
plugin, cwd is explicitly sethere
. So, the result fromresolve(appPath, entryModule)
is correct andAngularCompilerPlugin
is happy.When the webpack process is started from
karma-webpack
plugin, cwd is not set anywhere, so the default value is used. It is fine and works as expected whentest
command is executed from project directory regardless if--path
option is provided. It is not fine and the error is thrown in following cases:test
command is executed with--path
option from folder different from project directorytest
command is executed from CI where cwd is explicitly providedPR Checklist
What is the current behavior?
What is the new behavior?
Fixes/Implements/Closes #[Issue Number].